import { InputType, Field, ObjectType, PartialType } from '@nestjs/graphql';
import { BaseCreateSchema, PageInput, PaginatedResponse, SearchInput } from 'src/common/mongodb/commonSchema';
import { Menu } from '../entities/menu.entity';
import { GraphQLBigInt } from 'graphql-scalars';
import { MongoQueryScalar } from 'src/common/scalars/mongo.query.scalar';

@InputType()
export class CreateMenuInput extends BaseCreateSchema {
  @Field(() => String)
  name: string;

  @Field(() => String)
  title: string;

  @Field(() => String, { nullable: true })
  icon: string;

  @Field(() => String, { nullable: true })
  badge: string;

  @Field(() => String, { nullable: true })
  target: string;

  @Field(() => String)
  path: string;

  @Field(() => String, { nullable: true })
  link: string;

  @Field(() => String)
  component: string;

  @Field(() => Boolean)
  renderMenu: boolean;

  @Field(() => String, { nullable: true })
  parent?: string;

  @Field(() => [String], { nullable: 'itemsAndList' })
  permission?: (string | null)[] | null;

  @Field(() => Boolean)
  cacheable: boolean;
}

@InputType()
export class UpdateMenuInput extends PartialType(CreateMenuInput) {
  @Field(() => GraphQLBigInt, { nullable: true })
  _id: number;
}

@InputType()
export class SearchMenuInput {
  @Field(() => GraphQLBigInt, { nullable: true }) _id: number;

  @Field(() => MongoQueryScalar, { nullable: true }) name: string;
}

/** 搜索输入&排序输入 */
@InputType()
export class SearchMenuSortInput extends SearchInput<SearchMenuInput>(SearchMenuInput) {
}

@InputType()
export class PageMenuInput extends PageInput<SearchMenuInput>(SearchMenuInput) {
}

@ObjectType()
export class PageMenuResponse extends PaginatedResponse<Menu>(Menu) {
}



